<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
整数1：
<input type="text" id="a">
<br>
整数2:
<input type="text" id="q" >
<br>
<input type="button" value="相加" onClick="dev(add)">
<input type="button" value="相减" onClick="dev(mins)">
<input type="button" value="相乘" onClick="dev(mul)">
<input type="button" value="相除" onClick="dev(de)">
<br>
结果：
<input type="text" id="z">
<script>
	function fun(){
		console.log("hug")
	}
	function add(a,b){
	
		return a+b;
	}
		function mins(a,b){
		return a-b;
	}
		function mul(a,b){
			
			
		return a*b;
	
		}
		function de(a,b){
			if(a==0 || b==0){
				return alert("此程序已错误，请重修小学四年级");
			}
		return a/b;
	}
	function dev(fun){
		var a=parseInt(document.getElementById("a").value);
		var q=parseInt(document.getElementById("q").value);
		document.getElementById("z").value=fun(a,q);
	}
	</script>
</body>
</html>
